﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace Movie.web
{
    public partial class BeforLogin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = TextBox1.Text;
            string pwd = TextBox3.Text;
            string sex = RadioButton1.Checked ? "男" : "女";
            string phone = TextBox4.Text;
            string photo = Server.MapPath(FileUpload1.FileName);
           // Image1.ImageUrl = FileUpload1.FileName;
            string email=TextBox5.Text;

            string constr = "Data Source=.;Initial Catalog=iMovieDB;Integrated Security=True";
            SqlConnection con = new SqlConnection(constr);
            con.Open();
            string sql = string.Format("insert into Customer values('{0}','{1}','{2}','1','{3}','{4}','{5}','{6}')",name,pwd,phone,DateTime.Now,photo,sex,email);
            SqlCommand cmd = new SqlCommand(sql,con);
            int count = cmd.ExecuteNonQuery();
            if (count>0)
            {
                Response.Write("<script>alert('注册成功！');</script>");
                Response.Redirect("~/Login.aspx");
            }
            else
            {
                Response.Write("<script>alert('注册失败！');</script>");
            }

        }
    }
}